<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Login </title>
    <!-- Bootstrap core CSS -->
    <link href="../dist/css/bootstrap.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="../css/signin.css" rel="stylesheet">
    <script src="../js/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="../js/jquery.cookie.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#userid").focus();
            $("#userid").val($.cookie("UserID"));
            $("#userpwd").val($.cookie("UserPwd"));

            $("#btnlogin").click(function () {
                var userid = $("#userid").val();
                var userpwd = $("#userpwd").val();

                if (userid == "") {
                    alert("请输入用户名！");
                    $("#userid").focus();
                    return;
                }

                if (userpwd == "") {
                    alert("请输入密码！");
                    $("#userpwd").focus();
                    return;
                }

                if ($("#chkrmb")[0].checked == true) {
                    $.cookie("UserID", userid, { expires: 7 });
                    $.cookie("UserPwd", userpwd, { expires: 7 });
                } else {
                    $.cookie("UserID", "");
                    $.cookie("UserPwd", "");
                }

                $.ajax({ url: "ashx/login.ashx",
                    cache: false,
                    dataType: "text",
                    type: "post",
                    data: { "userid": userid, "userpwd": userpwd },
                    success: function (data) {
                        if (data != "") {
                            alert(data);
                            return;
                        }
                        window.location = "baoming.html";
                    }
                });
            });
        });
    </script>
    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="container">
        <div class="form-signin">
            <h2 class="form-signin-heading">
                后台登陆</h2>
            <input id="userid" type="text" class="form-control" placeholder="Email address" required
                autofocus>
            <input id="userpwd" type="password" class="form-control" placeholder="Password" required>
            <label class="checkbox">
                <input id="chkrmb" type="checkbox" value="remember-me" checked="checked">
                记住密码
            </label>
            <button class="btn btn-lg btn-primary btn-block" id="btnlogin">
                登陆</button>
            </form>
        </div>
        <!-- /container -->
        <!-- Bootstrap core JavaScript
    ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
</body>
</html>
